//
//  ChinaV.swift
//  Auscultation
//
//  Created by 来 on 2020/12/10.
//

import UIKit

class ChinaV: UIView {

    var mapView: WGMapCommonView!
    
    var label1_v: UIView!
    var label1: UILabel!
    
    var label2_v: UIView!
    var label2: UILabel!
    
    var label3_v: UIView!
    var label3: UILabel!
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        mapView = WGMapCommonView.init()
        mapView.pathFileName = "ChinaMapPaths.plist"
        mapView.infoFileName = "provinceInfo.plist"
        mapView.clickEnable = false
        mapView.backgroundColor = UIColor.white
        mapView.backColorD = UIColor.white
        mapView.nameColor = UIColor.darkGray
        mapView.lineColor = UIColor.init(lgf_HexString: "CFD4D9")
        mapView.frame = CGRect.init(x: 0, y: 0, width: 560, height: 470)
        mapView.transform = CGAffineTransform.init(scaleX: 0.5, y: 0.5)
        mapView.center = CGPoint.init(x: 560 / 4 + (((UIDevice.lgf_ScreenW - 34) - (560 / 2)) / 2), y: 470 / 4 + 20)
        addSubview(mapView)
        
        label1 = UILabel.init()
        label1.text = ""
        label1.font = UIFont.systemFont(ofSize: 12)
        label1.textColor = UIColor.init(lgf_HexString: "8D969D")
        addSubview(label1)
        label1.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview().multipliedBy(0.4)
            make.bottom.equalTo(-15)
        }
        label1_v = UIView.init()
        label1_v.layer.cornerRadius = 4
        addSubview(label1_v)
        label1_v.snp.makeConstraints { (make) in
            make.right.equalTo(label1.snp.left).offset(-5)
            make.centerY.equalTo(label1)
            make.width.height.equalTo(8)
        }
        
        label2 = UILabel.init()
        label2.text = ""
        label2.font = UIFont.systemFont(ofSize: 12)
        label2.textColor = UIColor.init(lgf_HexString: "8D969D")
        addSubview(label2)
        label2.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview().multipliedBy(1.0)
            make.bottom.equalTo(-15)
        }
        label2_v = UIView.init()
        label2_v.layer.cornerRadius = 4
        addSubview(label2_v)
        label2_v.snp.makeConstraints { (make) in
            make.right.equalTo(label2.snp.left).offset(-5)
            make.centerY.equalTo(label2)
            make.width.height.equalTo(8)
        }
        
        label3 = UILabel.init()
        label3.text = ""
        label3.font = UIFont.systemFont(ofSize: 12)
        label3.textColor = UIColor.init(lgf_HexString: "8D969D")
        addSubview(label3)
        label3.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview().multipliedBy(1.6)
            make.bottom.equalTo(-15)
        }
        label3_v = UIView.init()
        label3_v.layer.cornerRadius = 4
        addSubview(label3_v)
        label3_v.snp.makeConstraints { (make) in
            make.right.equalTo(label3.snp.left).offset(-5)
            make.centerY.equalTo(label3)
            make.width.height.equalTo(8)
        }
        
    }
    
    func setData(_ datas: [String]) {
        if datas.count < 3 {
            return
        }
        mapView.seletedAry = datas
        label1.text = datas[0].components(separatedBy: ":")[2]
        label2.text = datas[1].components(separatedBy: ":")[2]
        label3.text = datas[2].components(separatedBy: ":")[2]
        
        label1_v.backgroundColor = UIColor.init(lgf_HexString: datas[0].components(separatedBy: ":")[1])
        label2_v.backgroundColor = UIColor.init(lgf_HexString: datas[1].components(separatedBy: ":")[1])
        label3_v.backgroundColor = UIColor.init(lgf_HexString: datas[2].components(separatedBy: ":")[1])
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
